package com.wpre.fullprocess;

import com.wpre.luckymagicautotest.common.Utils;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2025-04-24
 * Time: 16:00
 */
public class Main {

    /**
     * 登录
     *
     * @param url    url
     * @param driver 驱动
     */
    private static void login(WebDriver driver, String url) {
        driver.get(url);
        driver.findElement(By.xpath("//input[@id='phoneNumber']")).sendKeys("13576674935");
        driver.findElement(By.xpath("//input[@id='password']")).sendKeys("12345678");
        driver.findElement(By.xpath("//form[@id='loginForm']/button[@type='submit']")).click();
    }

    private static void registerUser(WebDriver driver) {
        WebElement registerElement = driver.findElement(By.xpath("//a[@id='register']"));
        registerElement.click();

        WebElement nameInputElement = driver.findElement(By.xpath("//input[@id='name']"));
        nameInputElement.sendKeys("AutoTest1");

        WebElement mailInputElement = driver.findElement(By.xpath("//input[@id='mail']"));
        nameInputElement.sendKeys("123454321@qq.com");


    }

    public static void main(String[] args) throws InterruptedException {
        WebDriver driver = Utils.createDriver();
        login(driver, "http://8.138.194.44:8080/blogin.html");//登录
        Thread.sleep(2000);
        registerUser(driver);//注册用户

    }
}
